﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class UserEntityTypeConfiguration : IEntityTypeConfiguration<User>
    {
        public void Configure(EntityTypeBuilder<User> builder)
        {
            // 不使用output子句
            builder.ToTable(table => table.UseSqlOutputClause(false));

            builder
                .Property(user => user.UserName)
                .HasColumnName("Username");

            builder
                .Property(user => user.Description)
                .HasColumnName("Description")
                .HasColumnType("nvarchar(255)")
                .HasComment("用户描述")
                .IsRequired(false);

            builder
                .Property(user => user.Avatar)
                .HasColumnName("Avatar")
                .HasColumnType("varchar(255)")
                .HasComment("用户头像")
                .IsRequired(false);
        }
    }
}